home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / system / bsvc-1.000 / bsvc-1 / bsvc-1.0.4 / src / Sim68000 / cpu / decode.cxx next >
Encoding:
C/C++ Source or Header  |  1995-07-26  |  1.7 KB  |  53 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. // $Id: decode.cxx,v 1.1 1994/02/18 20:04:02 bmott Exp $
  3. ///////////////////////////////////////////////////////////////////////////////
  4. // decode.hxx 
  5. //
  6. // The Motorola 68000 instruction decoding stuff
  7. //
  8. // Sim68000 "Motorola 68000 Simulator"
  9. // Copyright (c) 1993
  10. // By: Bradford W. Mott
  11. // November 3,1993
  12. //
  13. ///////////////////////////////////////////////////////////////////////////////
  14. // $Log: decode.cxx,v $
  15. // Revision 1.1  1994/02/18  20:04:02  bmott
  16. // Initial revision
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19.  
  20. #include "m68000.hxx"
  21. #include <iostream.h>
  22.  
  23. DecodeEntry m68000::decode_table[] = {
  24.   #include "m68000DecodeTable.hxx"      // Built from instruction.list file
  25. };
  26.  
  27. ExecutionPointer *m68000::decode_cache_table = (void*)0;
  28.  
  29. ///////////////////////////////////////////////////////////////////////////////
  30. // Decode the given opcode
  31. ///////////////////////////////////////////////////////////////////////////////
  32. ExecutionPointer m68000::DecodeInstruction(int opcode)
  33. {
  34.   // Check to see if this opcode needs to be decoded
  35.   if(decode_cache_table[opcode] == (void*)0)
  36.   {
  37.     // Decode the opcode using a linear search (slow :-{ )
  38.     for(int s=0;s<(sizeof(decode_table)/sizeof(DecodeEntry));++s)
  39.     {
  40.       if ( (opcode & decode_table[s].mask) == decode_table[s].signature )
  41.       {
  42.         decode_cache_table[opcode]=decode_table[s].execute;
  43.       }
  44.     }
  45.  
  46.     // If not found then it's an invalid instruction
  47.     if(decode_cache_table[opcode] == (void*)0)
  48.       decode_cache_table[opcode]=&m68000::ExecuteInvalid;
  49.   }
  50.  
  51.   return(decode_cache_table[opcode]); 
  52. }
  53.